class MyPage extends BaseList {
    constructor(action, orderby, flag, $pagesize, $pagination, cokiePageSize, cokiePageIndex, cokieListResult, listUrl, delUrl) {
        super(action, orderby, flag, $pagesize, $pagination, cokiePageSize, cokiePageIndex, cokieListResult, listUrl, delUrl);
    }
    GetFilter(pageIndex) {
        let item = super.GetFilter(pageIndex);
        return JSON.stringify(item);
    }
    FetchAll() {
        this.$pagination.attr("_msh_page", 1);
        this.FetchForPage(1);
    }
    EmptyTableContent() {
        $("#tabData01 tbody").empty();
        this.$pagination.attr("_msh_page", 1);
    }
    SetTableContent(result) {
        $("#tabData01 tbody").empty();

        let content_01 = '';
        this.numCheckbox = result.length;  // 设置表格中checkbox的数量为表格的行数
        for (let i = 0; i < result.length; i++) {
            content_01 += '<tr _mash_id="' + result[i].eventLogId + '">';
            content_01 += '<td>' + formatNullData(result[i].modelName) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].operatorName) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].timeOfOperated) + '</td>';
            content_01 += '<td>' + formatNullData(result[i].typeOfOperated) + '</td>';
            content_01 += '<td style="border-right:none;">' + formatNullData(result[i].billOfOperated) + '</td>';
            content_01 += '</tr>';

            $("#tabData01 tbody").append(content_01);
            content_01 = '';
        }
        setOneTableRowColor("tabData01");
    }
    // 根据时间点整理数据
    DoCleanData() {
        showModal(685, 378, '选择数据整理时间点', parent.basePath + '/admin/event_log/clean.html', null, ($dialog) => {
            let _timePoint = "";
            let _exist = $.inArray($dialog, parent.arrDialog);
            if (_exist >= 0) {
                parent.arrDialog.splice($.inArray($dialog, parent.arrDialog), 1);
            }
            //做列表选择设置
            if (parent.choice_success) {
                _timePoint = parent.arrChoice[0][0];
                //清空数组
                parent.arrChoice.splice(0, parent.arrChoice.length);
                parent.choice_success = false;
            }
            // 清空数组
            parent.arrChoice.splice(0, parent.arrChoice.length);
            parent.choice_success = false;

            if (_timePoint !== "") {
                super.DoAjax(_timePoint, '/admin/event_log/delete.html', function (data, _this) {
                    if (parseInt(data) > 0) {
                        let currPage = $("abbr.page_indicator_block,#wrapper__navbar").attr("_msh_page");
                        _this.FetchForPage(currPage);
                        ShowSuccessMessagePanel('数据清理完成！');
                    }
                });
            }
        });
    }
}

var _Instance = null;

//-----------------------------------------------------------------------------
// 页面初始化
//-----------------------------------------------------------------------------
function onPageReady() {
    $("#page-size").val($.cookie("event_log_list_pagesize") === undefined ? 15 : $.cookie("event_log_list_pagesize"));
    // 删除已经保存的检索后的数据列表标识数组
    $.cookie("event_log_list_result", null);

    _Instance = new MyPage(0, null, 0,
            $("#page-size"),
            $("abbr.page_indicator_block,#wrapper__navbar"),
            "event_log_list_pagesize",
            "event_log_list_pageindex",
            "event_log_list_result",
            "/admin/event_log/fetchForPage.html",
            "");

    // 设置分页控制 （操作区域）
    $("#wrapper__navbar").swPagination({
        link_string: '/?page={page_number}',
        max_page: null,
        paged: function (page) {
            $("abbr.page_indicator_block,#wrapper__navbar").attr("_msh_page", page);
            _Instance.FetchForPage(page);
        }
    });

    _Instance.OnPageLoad();
}

// 画面大小或者位置移动
function onPageResize() {
}